package xml.uidElements.entry;

import java.util.ArrayList;
import java.util.List;

import xml.validations.FinderInputElements;
import xml.validations.StructuresValidator;

public class Structure extends AbstractStructure {

	protected String name;
	protected List<DataEntryElement> listDataItemsAndStructures;
	protected boolean optional;
	
	public Structure(String name, String data) {

		this.name = name;

		if (data != null && new StructuresValidator().isValid(data)) {
			listDataItemsAndStructures = new FinderInputElements().findInput(data);

		}else
			listDataItemsAndStructures = new ArrayList<DataEntryElement>();

	}

	public String getName() {
		return name;
	}

	public void addDataEntry(DataEntryElement d) {
		listDataItemsAndStructures.add(d);
		
	}

	public void setOptional(boolean optional) {
		this.optional = optional;
	}

	public boolean isOptional() {
		return optional;
	}

}